package com.ruoyi.hqfinance.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.hqfinance.domain.HqTransferDifferenceWeightSheet;
import com.ruoyi.hqfinance.domain.vo.HqTransferDifferenceWeightSheetVo;
import com.ruoyi.hqfinance.service.HqTransferDifferenceWeightSheetService;
import com.ruoyi.logistic.domain.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hq/differenceWeight")
@Api(tags = "总部财务-中转差重报表")
public class HqTransferDifferenceWeightSheetController {
    @Autowired
    private HqTransferDifferenceWeightSheetService hqTransferDifferenceWeightSheetService;

    @ApiOperation("搜索")
    @PostMapping("/search")
    public R search(@RequestBody HqTransferDifferenceWeightSheetVo vo) {
        if (vo.getStartTime() == null || vo.getEndTime() == null || vo.getIsShowProvince() == null || vo.getNetworkNameId() == null || vo.getCollectType() == null || vo.getDateType() == null || vo.getDetailType() == null){
            return R.fail("请传入查询所需的字段");
        }
        List<HqTransferDifferenceWeightSheet> sheets = hqTransferDifferenceWeightSheetService.collect(vo);
        if (sheets == null || sheets.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(PageInfo.info(sheets));
        }
    }
}
